<template>
	<view class="index">
		<view class="list" v-if="list.length > 0">
			<view class="uni-card" v-for="(item, index) in list" :key="index">
				<view class="uni-card-header">
					<view class="iconfont icon-dianpu"></view>
					<view>{{item.business_name}}</view>
					<view class="iconfont icon-you"></view>
				</view>
				<view class="uni-card-content">
					<view class="uni-card-content-inner">
						<view class="goods">
							<view class="goods-info">
								<view class="goods-img">
									<image :src="item.original_image" mode=""></image>
									
								</view>
								<view class="goods-name">{{item.goods_name}}</view>
								<view class="spec-name">{{item.spec_name}}</view>
							</view>
						</view>
						<view class="status">
							<view class="iconfont icon-tuikuantuihuo" v-if="item.type == 1"></view>
							<view class="iconfont icon-servicewuyoutuihuanhuo1" v-if="item.type == 2"></view>
							<view class="iconfont icon-quannianbaohuan" v-if="item.type == 3"></view>
							 <view>{{item.type_text}} {{item.status_text}}</view>
						</view>
						
					</view>
				</view>
				<view class="uni-card-footer">
					<view class="btn" @tap="cancel(item)" v-if="item.status != 0 && item.status != 2">撤销申请</view>
					
					<navigator :url="'detail?id='+item.id" class="btn">查看详情</navigator>
				</view>
			</view>
		</view>
		
		<view class="no-data" v-else>没有售后记录</view>
	</view>
</template>

<script>
	import Request from '../../common/request.js';
	
	export default {
		data() {
			return {
				list: []
			};
		},
		onShow() {
			this.getList();
		},
		methods: {
			getList() {
				var that = this;
				Request.send({
					url: 'after_sales/index',
					sCallback: function(res) {
						that.list = res.data;
					}
				})
			},
			//取消售后申请
            cancel: function(item) {
			    var that = this;
				uni.showModal({
					title:'提示',
					content: '确定撤销该申请吗？',
					success(e) {
						if(e.confirm == 1) {
							Request.send({
								url: 'after_sales/cancel',
								data: {id: item.id},
								sCallback: function(res) {
									item.status == 0;
									Request.alert(res.msg)
								}
							})
						}
					}
				})
            }
		}
	}
</script>

<style>
	.goods-info{
		display: flex;
		flex-direction: row;
		
		background: #fff;
		
	}
	
	.goods-info .goods-img image{
		width: 120upx;
		height: 120upx;
	}
	
	.goods-info .goods-name{
		color: #666;
		padding-left: 20upx;
	}
	
	.status{
		display: flex;
		flex-direction: row;
		align-items: center;
	}
	
	.status .iconfont{
		color: #e60012;
		margin-right: 10upx;
		font-size: 50upx;
		
	}
	
	.uni-card-footer{
		justify-content: flex-end;
	}
	
	.btn{
		border: 1upx solid #E60012;
		color: #e60012;
		margin-left: 20upx;
		padding: 0 20upx;
		border-radius: 10upx;
	}
</style>
